package com.example.routeplansystem.utils;

import java.util.Random;

/**
 * @Author: Lunaticer
 * @Create: 2022-02-11 11:18
 * @Tip: Keeping the eyes of the prize !
 * @Description: 邮箱验证码工具类！
 */
public class MailUtil {
    //邮箱验证码长度：
    private static final int MAIL_CODE_LENGTH = 5;

    //生成邮箱验证码：
    public static String generateRandomMailCode() {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";

        Random random = new Random();

        StringBuilder code = new StringBuilder();

        for (int i = 0; i < MAIL_CODE_LENGTH; i++) {
            int number = random.nextInt(base.length());
            code.append(base.charAt(number));
        }
        return code.toString();
    }
}
